<h:panelGroup layout="block"
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:c="http://java.sun.com/jstl/core"
  xmlns:nxd="http://nuxeo.org/nxweb/document"
  xmlns:nxu="http://nuxeo.org/nxweb/util"
  class="breadcrumb">

  <div class="printButton">
    <ui:include src="/incl/liveedit_create_actions.xhtml"/>
  </div>

  <div class="breadcrumbs">
    <h:form id="breadcrumbForm">

      <nxu:set var="coreRepositories" value="#{availableCoreRepositories}">
        <ul class="actionList jsBreadcrumbActionList">
          <li class="dropDownMenu button dropdown">
            <h:graphicImage value="/icons/UpFolder_icon.gif" alt="server" />
            <ul class="actionSubList">
              <ui:repeat var="coreRepository" value="#{coreRepositories}">
                <li>
                  <h:commandLink action="#{serverActions.selectRepository(coreRepository.name)}">
                    <h:outputText value="#{messages[coreRepository.label]}" />
                  </h:commandLink>
                </li>
              </ui:repeat>
            </ul>
          </li>
        </ul>
      </nxu:set>

      <c:if test="#{isNavigationBreadcrumb and not empty navigationContext.currentDomain}">
        <ul class="actionList jsBreadcrumbActionList">
          <li class="dropDownMenu button dropdown">
            <h:outputText value="#{nxd:titleOrId(navigationContext.currentDomain)}" />
            <ul class="actionSubList">
              <ui:repeat var="userDomain" value="#{breadcrumbActions.userDomains}">
                <li>
                  <nxd:restDocumentLink document="#{userDomain}">
                    <h:outputText value="#{nxd:titleOrId(userDomain)}" />
                  </nxd:restDocumentLink>
                </li>
              </ui:repeat>
            </ul>
          </li>
        </ul>
      </c:if>

      <c:if test="#{!empty backendPath}">
        <h:commandLink id="goToParentButton" action="#{breadcrumbActions.navigateToParent}"
          rendered="#{breadcrumbActions.isGoToParentButtonShown()}">
          <h:outputText value="#{breadcrumbActions.getPathEllipsis()}" />
        </h:commandLink>

        <ui:repeat var="pathElement" value="#{backendPath}" varStatus="status">
          <ui:fragment rendered="#{(status.first and (!pathElement.link or !breadcrumbActions.isUserDomain(pathElement.documentModel))) or !status.first}">
            <nxd:restDocumentLink document="#{pathElement.documentModel}"
              rendered="#{pathElement.link}">
              <h:outputText value="#{nxd:titleOrId(pathElement.documentModel)}" />
            </nxd:restDocumentLink>
            <h:outputText value="#{pathElement.name}" rendered="#{!pathElement.link}" />
          </ui:fragment>
        </ui:repeat>

      </c:if>
      <c:if test="#{empty backendPath}">
        <h:outputText value="#{multiNavTreeManager.virtualNavPath}" />
      </c:if>

    </h:form>
  </div>

  <div class="clear" />

  <h:outputScript target="#{pageJsTarget}">
    jQuery(document).ready(function() {
      jQuery("ul.jsBreadcrumbActionList").dropdown();
    });
  </h:outputScript>

</h:panelGroup>